<template>
  <div class="app-container">
    <uc-table url="admin/inEquipmentFunctionData/getEquipmentFunctionDataPage" name="设备实时数据" ref="realTimeDataTable" pageable table-border :search-form="searchForm">
      <template slot="searchForm">
        <el-form size="mini" :inline="true" :model="searchForm" class="demo-form-inline filter-container">
          <el-form-item>
            <el-input type="text" v-model="searchForm.content" placeholder="请输入报告内容" clearable @clear="clearInput()"></el-input>
          </el-form-item>
          <!--搜索输入框-->
          <el-form-item>
            <el-select v-model="searchForm.equipmentId" placeholder="请选择设备" style="width: 100%" clearable @clear="clearInput1()">
              <el-option v-for="(item,index) in equipmentList" :key="index"  :value="item.ucId" :label="item.disPlayName"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item v-if="enterPriseHidden">
            <el-select v-model="searchForm.enterpriseId" placeholder="请选择主体" clearable @clear="clearInput2()">
              <el-option v-for="(item,index) in enterpriseDominantList" :key="index"  :value="item.ucId" :label="item.name"></el-option>
            </el-select>
          </el-form-item>
          <!--搜索按钮--新增按钮-->
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" class="filter-item" @click="handleSearch()">查询</el-button>
          </el-form-item>
        </el-form>
      </template>
      <template slot="columns">
        <el-table-column prop="equipmentName" label="设备名称" align="left" show-overflow-tooltip></el-table-column>
        <el-table-column prop="enterpriseName" label="所属主体" align="left" show-overflow-tooltip ></el-table-column>
        <el-table-column prop="content" label="报告内容" align="left" show-overflow-tooltip></el-table-column>
        <el-table-column prop="reportData" label="报告数据" align="left"></el-table-column>
        <el-table-column prop="reportTime" label="报告时间" align="left"></el-table-column>
      </template>
    </uc-table>
  </div>
</template>

<script>
import UcTable from "@/components/UcTable/index.vue";
import {getEquipmentList} from "@/api/equipment";
import {getInEnterpriseList} from "@/api/enterprise";
import {deleteInEquipmentMaintenance} from "@/api/equipmentMaintenance"
import {getInEnterpriseDominantList} from "@/api/enterpriseDominant";
export default {
  name: "realTimeDataList",
  components: {UcTable},
  data(){
    return{
      searchForm:{
      },
      equipmentList:[],
      enterpriseDominantList:[],
    }
  },
  computed:{
    enterPriseHidden(){
      let roleCode = this.$store.getters.roleCode;
      return roleCode=="ADMIN"||roleCode=="XT-ADMIN"||roleCode=="ZD-ADMIN"||roleCode=="DD-ADMIN"||roleCode=="JW-ADMIN"
    }
  },
  created() {
    this.getEquipmentList()
    this.getInEnterpriseDominantList()
  },
  methods:{
    handleSearch(){
      this.$refs.realTimeDataTable.getTableData(1)
    },
    clearInput(){
      this.searchForm.content=null
      this.handleSearch()
    },
    clearInput1(){
      //清除输入框
      this.searchForm.equipmentId = null
      this.handleSearch()
    },
    clearInput2(){
      //清除输入框
      this.searchForm.enterpriseId = null
      this.handleSearch()
    },
    getEquipmentList(){
      getEquipmentList({deleted:false}).then(res=>{
        this.equipmentList = res.data
      }).catch(error=>{

      })
    },
    getInEnterpriseDominantList(){
      getInEnterpriseDominantList({deleted:false}).then(res=>{
        this.enterpriseDominantList = res.data
      }).catch(error=>{

      })
    }
  }
}
</script>

<style scoped>

</style>